﻿using IoC.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace WebApi.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class IocController : ControllerBase
    {
        private readonly ILogger<IocController> _logger;

        public IocController(ILogger<IocController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="cellPhone">使用 FromServices attribute 标示被注入的方法参数</param>
        /// <returns></returns>
        [HttpGet]
        [Route("json")]
        public IActionResult ReturnJson([FromServices] ICellPhone cellPhone, [FromServices] IMicroPhone microPhone)
        {
            return new JsonResult(cellPhone);
        }
    }
}